import {queryBorrowedInfo} from "@/api";

const state = {
    readerInfo: [],
    booksInfo:[],
    borrowInfoList:[]
};
const mutations = {
    QUERYBORROWEDINFO(state, borrowInfo) {
        state.readerInfo.push( borrowInfo.readerJoinType)
        state.booksInfo= borrowInfo.borrowedList;
        state.borrowInfoList=borrowInfo.borrowInfoList
    },
    CLEARINFO(state){
        state.readerInfo=[]
        state.booksInfo=[]
        state.borrowInfoList=[]
    }

};
const actions = {
    async queryBorrow({commit}, params = {}) {
        let response = await queryBorrowedInfo(params);
        if (response.code == 200) {
            commit("QUERYBORROWEDINFO", response.data)
        }
    }
};
const getters = {};

export default {
    state,
    mutations,
    actions,
    getters
}
